{% extends 'base.html' %}

{% block styles %}
  {{ super() }}
  <link href="{{ url_for_static('static', filename='css/main/index.css') }}" rel="stylesheet">
  <link href="{{ url_for_static('static', filename='plugins/tippyjs/tippy.js/themes/light.css') }}" rel="stylesheet">
  <link href="{{ url_for_static('static', filename='plugins/tippyjs/tippy.js/themes/light-border.css') }}" rel="stylesheet">
  <link href="{{ url_for_static('static', filename='plugins/tippyjs/tippy.js/themes/material.css') }}" rel="stylesheet">
  <link href="{{ url_for_static('static', filename='plugins/tippyjs/tippy.js/themes/translucent.css') }}" rel="stylesheet">
{% endblock styles %}

{% block body_attribs %}
class="bg-gradient-grey"
{% endblock body_attribs %}

{% block app_content %}
<div class="container-fluid">
  <div class="d-flex align-items-center justify-content-between my-4">
    <h1 class="h3 font-weight-bold mb-0">总览面板</h1>
{#    <a href="#" class="d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm"><i class="fas fa-download fa-sm text-white-50"></i> 报告生成</a>#}
  </div>
  <div class="row">
    <div class="col-xl-3 col-md-6 mb-4">
      <div class="card border-left-primary shadow h-100 py-2">
        <div class="card-body">
          <div class="row no-gutters align-items-center">
            <div class="col mr-2">
              <div class="font-weight-bold text-primary text-uppercase mb-1">历史构建次数</div>
              <div class="h5 mb-0 font-weight-bold">{{ total_dispatcher_count }}</div>
            </div>
            <div class="col-auto">
              <i class="fas fa-calendar fa-2x" style="color:#dcdeea!important"></i>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="col-xl-3 col-md-6 mb-4">
      <div class="card border-left-success shadow h-100 py-2">
        <div class="card-body">
          <div class="row no-gutters align-items-center">
            <div class="col mr-2">
              <div class="font-weight-bold text-success text-uppercase mb-1">当前用户历史构建次数</div>
              <div class="h5 mb-0 font-weight-bold">{{ total_dispatcher_count_current_user }}</div>
            </div>
            <div class="col-auto">
              <i class="fas fa-calendar fa-2x" style="color:#dcdeea!important"></i>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="col-xl-3 col-md-6 mb-4">
      <div class="card border-left-info shadow h-100 py-2">
        <div class="card-body">
          <div class="row no-gutters align-items-center">
            <div class="col mr-2">
              <div class="font-weight-bold text-info text-uppercase mb-1">定时任务数</div>
              <div class="h5 mb-0 font-weight-bold cursor-pointer" id="show-project-scheduler-info" style="text-decoration:underline;">
                {{ scheduler_enable_count }}
              </div>
              <div style="display: none;">
                <div class="table-responsive" style="width: 30vw; height: 30vh;">
                  <table class="table table-striped">
                    <thead>
                      <tr>
                        <th scope="col">项目编号</th>
                        <th scope="col">项目名称</th>
                        <th scope="col">cron表达式</th>
                        <th scope="col">预计下次执行时间</th>
                      </tr>
                    </thead>
                    <tbody>
                    {% for scheduler in schedulers %}
                      <tr>
                        <td>{{ scheduler.id }}</td>
                        <td><a href="/module/?project_id={{ scheduler.id }}" target="_blank">{{ scheduler.name }}</a></td>
                        <td>{{ scheduler.cron }}</td>
                        <td>{{ scheduler.next_fire_time }}</td>
                      </tr>
                    {% endfor %}
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
            <div class="col-auto">
              <i class="fas fa-clock fa-2x" style="color:#dcdeea!important"></i>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="col-xl-3 col-md-6 mb-4">
      <div class="card border-left-warning shadow h-100 py-2">
        <div class="card-body">
          <div class="row no-gutters align-items-center">
            <div class="col mr-2">
              <div class="font-weight-bold text-warning text-uppercase mb-1">已编写案例个数</div>
              <div class="h5 mb-0 font-weight-bold">{{ total_case_count }}</div>
            </div>
            <div class="col-auto">
              <i class="fas fa-clipboard-list fa-2x" style="color:#dcdeea!important"></i>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-xl-6 col-lg-6">
      <div class="card shadow mb-4">
        <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
          <h6 class="m-0 font-weight-bold text-primary">近期构建次数统计</h6>
        </div>
        <div class="card-body">
{#          <div class="chart-area">#}
          <div id="echarts-line-last-dispatch-count" style="display: block; height: 40vh; width: 100%;"></div>
{#          </div>#}
        </div>
      </div>
    </div>
    <div class="col-xl-6 col-lg-6">
      <div class="card shadow mb-4">
        <div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
          <h6 class="m-0 font-weight-bold text-primary">近期构建次数统计(当前用户)</h6>
        </div>
        <div class="card-body">
{#          <div class="chart-area">#}
          <div id="echarts-line-last-dispatch-count-current-user" style="display: block; height: 40vh; width: 100%;"></div>
{#          </div>#}
        </div>
      </div>
    </div>
  </div>
</div>

{% endblock app_content %}

{% block scripts %}
  {{ super() }}
  <script src="{{ url_for_static('static', filename='plugins/echarts/echarts.min.js') }}"></script>
  <script src="{{ url_for_static('static', filename='plugins/tippyjs/@popperjs/core/dist/umd/popper.min.js') }}"></script>
  <script src="{{ url_for_static('static', filename='plugins/tippyjs/tippy.js/dist/tippy-bundle.umd.min.js') }}"></script>
  <script src="{{ url_for_static('static', filename='js/main/index.js') }}"></script>
  <script>
    var echart_line_last_dispatch_dataset_source = {{ echart_line_last_dispatch_dataset_source|safe }};
    var echart_line_last_dispatch_current_user_dataset_source = {{ echart_line_last_dispatch_current_user_dataset_source|safe }};
  </script>
{% endblock %}